home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / COMMUNIC / TERMINAL / 1589.ZIP / TERMCTRL.C < prev    next >
Text File  |  1989-04-13  |  3KB  |  95 lines

  1.  
  2. #include "windows.h"
  3. #include <stdio.h>
  4. #include <fcntl.h>
  5. #include <stdarg.h>
  6. #include "icu_user.h"
  7. #include "term.h"
  8. #include "termdefs.h"
  9.  
  10. /* */
  11. /*doc************************************************************************
  12. *
  13. *     NAME
  14. *
  15. *     ProcessCtrl() - Converts a CONTROL character into Windows commands
  16. *
  17. *     FORMAT
  18. *
  19. *     ProcessCtrl( Control Character )
  20. *
  21. *     DESCRIPTION
  22. *          This function was called by ReadLine() when a Control character is
  23. *          read.  The function performs functions needed to cary out whatever
  24. *          function the control character ment.
  25. *
  26. *          NOTE:  I have not written code for every possible control character.
  27. *              I needed the program to handle control characters that were
  28. *              thrown out by curses while curses was drawing graphics and stuff.
  29. *              Open the Diag. dialog window with verbose on to see if you are
  30. *              getting control characters that are not being supported.
  31. *
  32. *     RETURN VALUE
  33. *     TRUE  - Escape sequence was executed
  34. *     FALSE - Escape character is not supported.
  35. *
  36. *     MODIFIES
  37. *
  38. *     REFERENCES
  39. *
  40. *end************************************************************************/
  41. ProcessCtrl( CtrlCode )
  42. char CtrlCode;
  43. {
  44. int  i, ReturnValue ;
  45.  
  46. ReturnValue = TRUE;
  47.  
  48. TermShowCaret( FALSE );              /* Hide the caret */
  49. switch( CtrlCode ) {
  50.    case 0x07:                        /* Sound BELL     */
  51.        Beep();
  52.        break;
  53.    case 0x08:                        /* Cursor Left    */
  54.        if ( next_char > 0 ) {
  55.            curs_pos.x -= char_w;
  56.            next_char--;
  57.            }
  58.        break;
  59.    case 0x0A:                        /* Cursor Down    */
  60.        UpdateCursPos(DOWN_LINE);     /* Advance to next line- NO CR  */
  61.        break;
  62.    case 0x0B:                        /* Cursor Up      */
  63.        if ( next_line > 0 ) {
  64.            curs_pos.y -= char_h;
  65.            next_line--;
  66.            }
  67.        break;
  68.    case 0x0C:                        /* Cursor Right   */
  69.        UpdateCursPos(NEXT_CHAR);
  70.        break;
  71.    case 0x0D:                        /* Cursor to Start of Line */
  72.        curs_pos.x = char_w;
  73.        next_char  = 0;
  74.        break;
  75.    case 0x1E:                        /* Home Cursor */
  76.        next_char  = 0;
  77.        next_line  = 0;
  78.        curs_pos.x = char_w;
  79.        curs_pos.y = 1;
  80.        break;
  81.    case 0x1F:                        /* LineFeed     */
  82.        fileput("Control- line Feed");
  83.        UpdateCursPos(NEXT_LINE);     /* Advance to next line  */
  84.        break;
  85.    default:
  86.        fileput("Control character [%d]:[%xH] not supported.",CtrlCode,CtrlCode);
  87.        ReturnValue = FALSE;
  88.        break;
  89.    }
  90.  
  91. TermShowCaret( TRUE );               /* Show the caret */
  92. return( ReturnValue );
  93. }                                    /** End of termCTRL.c **/
  94.  
  95.